﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KMFrame.Core;
using SzCourt.Logic.BLL;
using KMFrame.Permission.Util;

namespace SzCourt.WebSite.reporter
{
    public partial class news : System.Web.UI.Page
    {
        public int PageIndex = 1;
        public int PageSize = 10;
        public int TotalPage = 1;
        private string Keyword = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            getSessionInfo();
            getList();
        }

        private void getSessionInfo()
        {
            if (!SessionBox.CheckUserSession())
            {
                Response.Redirect("/reporter/login.aspx");
            }
            this.spUserName.InnerHtml = SessionBox.GetUserSession().UserName;
            this.spDate.InnerHtml = DateTime.Now.ToString();
        }

        private void getList()
        {
            this.PageIndex = string.IsNullOrEmpty(Request.QueryString["PageIndex"]) ? 1 : Convert.ToInt32(Request.QueryString["PageIndex"]);
            this.Keyword = string.IsNullOrEmpty(Request.QueryString["Keyword"]) ? "" : Request.QueryString["Keyword"];

            PageParam param = new PageParam();
            param.PageIndex = this.PageIndex;
            param.PageSize = this.PageSize;

            ReporterHome reporterHome = new ReporterHome();
            PageResult result = (PageResult)reporterHome.GetReporterHomeList(param, Keyword);

            if (result != null)
            {
                this.rptDataList.DataSource = result.ResultList;
                this.rptDataList.DataBind();

                this.pager1.RecordCount = result.TotalCount;
                this.pager1.TotalPage = result.PageCount;
                this.pager1.PageIndex = this.PageIndex;
                this.pager1.PageSize = this.PageSize;
                this.pager1.LinkUrl = "/reporter/news.aspx?PageIndex=" + this.PageIndex.ToString();
                this.pager1.IsResult = false;
                this.pager1.IsNext = "2";
            }


        }
    }
}